home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 2.iso / STUTTGART / LANG / C / LIB / UNIXLIB37B / !UnixLib37 / src / clib / sys / h / unix < prev    next >
Text File  |  1996-11-09  |  5KB  |  211 lines

  1. /****************************************************************************
  2.  *
  3.  * $Source: /unixb/home/unixlib/source/unixlib37/src/clib/sys/h/RCS/unix,v $
  4.  * $Date: 1996/11/06 22:01:41 $
  5.  * $Revision: 1.5 $
  6.  * $State: Rel $
  7.  * $Author: unixlib $
  8.  *
  9.  * UNIX is a registered trademark of AT&T Bell Laboratories
  10.  *
  11.  * $Log: unix,v $
  12.  * Revision 1.5  1996/11/06 22:01:41  unixlib
  13.  * Yet more changes by NB, PB and SC.
  14.  *
  15.  * Revision 1.4  1996/10/30 22:04:51  unixlib
  16.  * Massive changes made by Nick Burret and Peter Burwood.
  17.  *
  18.  * Revision 1.3  1996/07/21 22:15:12  unixlib
  19.  * CL_0001 Nick Burret
  20.  * Improve memory handling. Remove C++ library incompatibilities.
  21.  * Improve file stat routines.
  22.  *
  23.  * Revision 1.2  1996/05/06 09:03:13  unixlib
  24.  * Updates to sources made by Nick Burrett, Peter Burwood and Simon Callan.
  25.  * Saved for 3.7a release.
  26.  *
  27.  * Revision 1.1  1996/04/19 21:23:56  simon
  28.  * Initial revision
  29.  *
  30.  ***************************************************************************/
  31.  
  32. #ifndef __SYS_UNIX_H
  33. #define __SYS_UNIX_H
  34.  
  35. #ifndef __UNIXLIB_TYPES_H
  36. #include <unixlib/types.h>
  37. #endif
  38. #ifndef __SYS_TTY_H
  39. #include <sys/tty.h>
  40. #endif
  41. #ifndef __SETJMP_H
  42. #include <setjmp.h>
  43. #endif
  44. #ifndef __SYS_DEV_H
  45. #include <sys/dev.h>
  46. #endif
  47. #ifndef __SYS_TIME_H
  48. #include <sys/time.h>
  49. #endif
  50. #ifndef __SYS_RESOURCE_H
  51. #include <sys/resource.h>
  52. #endif
  53. #ifndef __LIMITS_H
  54. #include <limits.h>
  55. #endif
  56. #ifndef __UNIXLIB_SIGSTATE_H
  57. #include <unixlib/sigstate.h>
  58. #endif
  59.  
  60. #ifdef __cplusplus
  61. extern "C" {
  62. #endif
  63.  
  64. /* the 2 functions below are automatically called in normal circumstances */
  65.  
  66. extern void __unixinit(void);    /* initialise UNIX */
  67. extern void __unixexit(void);    /* shutdown UNIX */
  68.  
  69. extern int __fdalloc(void);
  70.  
  71. struct __process
  72.   {
  73.     /* This process has a parent process.  */
  74.     unsigned int has_parent : 1;
  75.     /* This process terminated through a signal handler.  */
  76.     unsigned int signal_exit : 1;
  77.     /* This process terminated with a core dump.  */
  78.     unsigned int core_dump : 1;
  79.     /* This process just stopped.  */
  80.     unsigned int stopped : 1;
  81.     /* This process is controlling the tty. */
  82.     unsigned int tty_control : 1;
  83.     /* The type of tty this process is controlling.  */
  84.     unsigned int tty_type : 8;
  85.     /* The number of the signal we terminated with.  */
  86.     unsigned int signal : 8;
  87.     /* The return code of this process.  */
  88.     unsigned int return_code : 8;
  89.   };
  90.  
  91. struct __child_process
  92.   {
  93.     __uid_t uid;
  94.     __gid_t gid;
  95.     __pid_t pid;
  96.     int    ppri, gpri, upri;
  97.     struct __process status;
  98.     struct rusage usage;
  99.     /* Process context.  */
  100.     jmp_buf vreg;
  101.   };
  102.  
  103. #define _PROCMAGIC 0xfedcfa5f
  104.  
  105. struct proc
  106.   {
  107.   /* Magic word */
  108.   int __magic;
  109.   /* main(argc,argv) */
  110.   int argc;
  111.   char **argv, *argb;
  112.   /* FD set */
  113.   struct file file[MAXFD];
  114.   struct tty *tty;
  115.   /* real/effective user ID */
  116.   __uid_t uid, euid;
  117.   /* real/effective group ID */
  118.   __gid_t gid, egid;
  119.   /* process group ID */
  120.   __pid_t pgrp;
  121.   /* process id */
  122.   __pid_t pid;
  123.   /* parent process id */
  124.   __pid_t ppid;
  125.   /* priority: process, process group, user process */
  126.   int ppri, gpri, upri;
  127.   /* File creation mask.  */
  128.   __mode_t umask;
  129.   /* status for this particular process */
  130.   struct __process status;
  131.   /* interval timers */
  132.   struct itimerval itimers[__MAX_ITIMERS];
  133.   /* resource limits */
  134.   struct rlimit limit[RLIMIT_NLIMITS];
  135.   /* current resource usage */
  136.   struct rusage usage;
  137.   /* parent's struct proc */
  138.   struct proc *pproc;
  139.   /* Details recorded about stopped or terminated children.  */
  140.   struct __child_process child[CHILD_MAX];
  141.   /* The signal states for this process. */
  142.   struct unixlib_sigstate sigstate;
  143.   /* Set to 1 if this process is currently sleeping, orphaned or stopped.
  144.      These could change at any time.  */
  145.   volatile int sleeping, orphaned, stopped;
  146.   /* Preemptive-signal states.  */
  147.   struct unixlib_signal_preempt *sigpreempt[NSIG];
  148.   /* Process context.  */
  149.   jmp_buf vreg;
  150.   };
  151.  
  152. extern struct proc *__u;    /* current process */
  153.  
  154. struct sfile            /* special file list */
  155.   {
  156.   char        *name;
  157.   __dev_t     dev;
  158.   };
  159.  
  160. extern struct sfile __sfile[];        /* defined in open.c */
  161.  
  162. struct sdir                /* special directory list */
  163.   {
  164.   char        *name;
  165.   char        *riscos_name;
  166.   };
  167.  
  168. #define MAXSDIR 16
  169.  
  170. extern struct sdir __sdir[MAXSDIR];    /* defined in unix.c */
  171.  
  172. #define MAXSFIX 48
  173.  
  174. extern char *__sfix[MAXSFIX];        /* special suffix list */
  175.  
  176. struct pipe
  177.   {
  178.   struct file    *p[2];
  179.   char        *file;
  180.   struct pipe    *next;
  181.   };
  182.  
  183. extern struct pipe *__pipe;    /* list of currently active pipes */
  184.  
  185.  
  186. extern int __envcnt,__envsiz;        /* count of strings in **environ */
  187. extern char *__addenv(const char *,char *);    /* add/replace string,value */
  188. extern char *__chkenv(const char *); /* check if string exists in **environ */
  189.  
  190. extern char *__getenv(const char *,int);
  191. extern int __intenv(const char *,int); /* integer getenv() - 0 if nonexistent */
  192.  
  193. extern char *__permstr(const char *);    /* malloc() + memcpy() */
  194.  
  195. /* Find first freely available child.  */
  196. extern int __find_free_child (void);
  197. extern void __printf_init (void);
  198.  
  199. /* Make unique (but not random) file serial numbers for readdir()
  200.    and stat().  */
  201. extern unsigned int __get_file_serial_no (char *);
  202.  
  203. /* Print an error and exit the process.  */
  204. extern void __unixlib_fatal (char *s);
  205.  
  206. #ifdef __cplusplus
  207.     }
  208. #endif
  209.  
  210. #endif
  211.